package cn.itutu.demo.junit;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

/**
 * Created by itutu on 2018/4/16.
 * Description:
 */
public class Junit4Demo_Timeout {
    Calculator calculator = new Calculator();

    @Test(timeout = 1000)
    public void testTimeout1() throws Exception {
        System.out.println("timeout 1000 | sleep 999");
        Thread.sleep(500);
        assertEquals(9, calculator.add(3,6));
    }
    @Test(timeout = 1000)
    public void testTimeout2() throws Exception {
        System.out.println("timeout 1000 | sleep 1000");
        Thread.sleep(1000); //@TODO 这个结果好像不确定,有时候超出1000fail,有时候又在1000之内success
        assertEquals(9, calculator.add(3,6));
    }
    @Test(timeout = 1000)
    public void testTimeout3() throws Exception {
        System.out.println("timeout 1000 | sleep 2000");
        Thread.sleep(2000);
        assertEquals(9, calculator.add(3,6));
    }
}
